#pragma once
#include <string>
#include <list>
namespace libnt
{
	using namespace std;
	typedef enum arg_type_t{
		_opt_none = 0x00,
		_opt_argu = 0x01,
		_opt_swit = 0x02,
		_opt_opti = 0x03,
	}arg_type;

#pragma pack(1)
	typedef struct argument_t 
	{
		char		flag;
		char*		valp;
	}argument;
#pragma pack()

	class arg_parse
	{
	private:
		class _impl
		{
		public:
			_impl();
			virtual ~_impl();
			void trim(string& out,const char* space=" \t");
			bool _check_swit(argument& argu);
			bool _parseopt(const char* option);
			bool _checkopt();
			bool _parse(int argc,char* argv[],const char* option);
			argument* _getopt();
			argument* _getarg();

		private:
			list<argument> m_args_in;

			list<argument> m_args;
			list<argument>::iterator m_arg;

			list<argument> m_opts;
			list<argument>::iterator m_opt;


		private:
			bool isalnums(const char* str);
			bool isoption(const char* str);
			arg_type get_type(char* str);
		};  //end _impl

	public:
		arg_parse();
		virtual ~arg_parse();
		void trim(string& out,const char* space=" \t");
		bool parse(int argc,char* argv[],const char* option);
		argument* getopt();
		argument* getarg();
	private:
		_impl* m_impl;
	};
}

